/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package base;

import com.db4o.Db4oEmbedded;
import com.db4o.ObjectContainer;
import com.db4o.ObjectSet;
import java.io.File;
import java.util.LinkedList;
import java.util.List;

import logicaDePredicados.PredicateLogic;
import predicatesAndQuerys.RetrieveAllPredicateLogic;

/**
 *
 * @author John Marlo
 */
public class KnowledgeBaseManager {

    public static List<PredicateLogic> ObtainEntireKnowledgeBase(File knowledgeBaseFile) {
        List<PredicateLogic> returnList =null;
        ObjectContainer db = null;
        try {
            db = Db4oEmbedded.openFile(Db4oEmbedded.newConfiguration(), knowledgeBaseFile.getAbsolutePath());
            ObjectSet<PredicateLogic> objectSet = db.query(new RetrieveAllPredicateLogic());
            returnList= new LinkedList<PredicateLogic>();
            for (PredicateLogic predicateLogic : objectSet) {
                returnList.add(predicateLogic);

            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (db != null) {
                db.rollback();
                db.close();
            }
        }

        return returnList;
    }
}
